package com.yicong.ants;


import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

public class TipsDialog {
    private Dialog dialog;
    private View mView;

    public TipsDialog(Context context, int layoutId) {
        dialog = new Dialog(context);
        mView = LayoutInflater.from(context).inflate(layoutId, null);
        mView.findViewById(R.id.iv_exit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        dialog.setCancelable(false);
        dialog.setContentView(mView);
    }

    public void setTitle(String title) {
        TextView textView = mView.findViewById(R.id.title);
        textView.setText(title);
    }

    public void setContext(String context){
        TextView textView = mView.findViewById(R.id.content);
        textView.setText(context);
    }

    public void setSureListener(View.OnClickListener listener){
        mView.findViewById(R.id.tv_sure).setOnClickListener(listener);
    }

    public void showDialog() {
        if (!dialog.isShowing())
            dialog.show();
    }

    public void dismiss() {
        dialog.dismiss();
    }
}
